﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Xml.Serialization;

namespace MailSender
{
    [Serializable]
    public class Settings
    {
        private List<string> _attache = new List<string> {};//(new string[] { "asdasdasd", "qweqweqw", "1234132412" });

        public string AddressFile { get; set; }
        public string Connection { get; set; }

        public string Host { get; set; }
        public int Port { get; set; }
        public string User { get; set; }
        public string Password { get; set; }
        public string FromAddress { get; set; }
        public bool UseSsl { get; set; }

        public int SendInTime { get; set; }
        public int SendInterval { get; set; }

        public string Subject { get; set; }
        public string Body { get; set; }
        public bool BodyInHtml { get; set; }

        public List<string> Attache
        {
            get { return _attache; }
            set { _attache = value; }
        }

        public void Save(string fileName)
        {
            XmlSerializer ser = new XmlSerializer(this.GetType());

            using (var stream = new FileStream(fileName, FileMode.Create))
            {
                ser.Serialize(stream, this);
            }
        }

        public static Settings Load(string fileName)
        {
            XmlSerializer ser = new XmlSerializer(typeof(Settings));
            using (var stream = new FileStream(fileName, FileMode.OpenOrCreate))
            {
                return (Settings)ser.Deserialize(stream);
            }
        }
    }
}
